#!/bin/sh

IDIR="$(echo $1 | sed -e 's,/*$,,')"
if [ -z "$IDIR" ] || [ ! -d $IDIR ]; then
    echo "swx - version $VERSION"
	echo "Usage: $0 [dir]"
	exit 1
fi

. $PWD/swx.conf

# Setup output dir structure
CDIR=$PWD
ODIR="$CDIR/$(basename $IDIR).gopher"
mkdir -p $ODIR

cp -uv $IDIR/* $ODIR/

find $ODIR -iname "*$EXT" -exec txt2tags -t txt '{}' \;
find $ODIR -iname "*$EXT" -exec rm '{}' \;

figlet "$TITLE" > "$ODIR"/gophermap
echo "\n*" >> "$ODIR"/gophermap


exit 0
